package com.jinyang.plugindemo.activity

import android.content.Context
import android.content.Intent
import android.os.Bundle

/**
 * @Author:         LiuJinYang
 * @CreateDate:     2021/12/13
 * @Description:
 */
class ProxyReflectActivity : ProxyBaseActivity() {
    private var reflectActivityLifeCircle: ReflectActivityLifeCircle? = null


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        reflectActivityLifeCircle= ReflectActivityLifeCircle(pluginActivityName,pluginClassLoader)
        reflectActivityLifeCircle?.attach(this)
        reflectActivityLifeCircle?.onCreate(savedInstanceState)
    }

    override fun onStart() {
        super.onStart()
        reflectActivityLifeCircle?.onStart()
    }

    override fun onResume() {
        super.onResume()
        reflectActivityLifeCircle?.onResume()
    }

    override fun onPause() {
        super.onPause()
        reflectActivityLifeCircle?.onPause()
    }

    override fun onStop() {
        super.onStop()
        reflectActivityLifeCircle?.onStop()
    }

    override fun onDestroy() {
        super.onDestroy()
        reflectActivityLifeCircle?.onDestroy()
    }

    companion object{
        fun startPluginActivity(context: Context, pluginPath: String, activityName: String) {
            val intent = Intent(context, ProxyReflectActivity::class.java)
            intent.putExtra("pluginPath", pluginPath)
            intent.putExtra("activityName", activityName)
            context.startActivity(intent)
        }
    }

}